package com.kefu.robot.vo;

import java.util.Set;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Size;

import cn.hutool.core.bean.BeanUtil;
import com.kefu.common.context.KefuContext;
import com.kefu.common.vo.AbstractUpdateVo;
import com.kefu.robot.model.RobotDoc;
import com.kefu.robot.model.RobotDocLink;
import com.kefu.robot.model.RobotDocQuestion;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@ApiModel(description = "知识词条")
public class RobotDocUpdateVo extends AbstractUpdateVo<RobotDoc, String> {
    @NotEmpty
    @ApiModelProperty(name = "id", value = "主键")
    private String docId;
    @Size(max = 32)
    @ApiModelProperty(name = "docTypeId", value = "词条分类")
    private String docTypeId;
    @ApiModelProperty(name = "docPattern", value = "模式：0单轮问题，1多轮问题")
    private Integer docPattern;
    @ApiModelProperty(name = "docStatus", value = "词条状态：0停用，1启用")
    private Integer docStatus;
    @ApiModelProperty(name = "docAnswer", value = "答案")
    private String docAnswer;
    @ApiModelProperty(name = "docQuestion", value = "标准问题")
    private String docQuestion;
    @ApiModelProperty(name = "timeMode", value = "有效期：0永久生效，1有截止时间")
    private Integer timeMode;
    @ApiModelProperty(name = "startTime", value = "开始时间")
    private Long startTime;
    @ApiModelProperty(name = "endTime", value = "结束时间")
    private Long endTime;
    @ApiModelProperty(name = "similarUpdate", value = "问题列表是否修改，0没改，1改了")
    private int similarUpdate;
    @ApiModelProperty(name = "linkUpdate", value = "关联问题列表是否修改，0没改，1改了")
    private int linkUpdate;
    @ApiModelProperty(name = "similarQuestions", value = "相似问题")
    private Set<RobotDocQuestion> similarQuestions;
    @ApiModelProperty(name = "linkQuestions", value = "关联问题")
    private Set<RobotDocLink> linkQuestions;
    @ApiModelProperty(value = "是否挂机：0否，1是")
    private Integer hangupMode;
    @ApiModelProperty(value = "是否跳转：0否，1是")
    private Integer nextMode;

    @Override
    public RobotDoc convert() {

        RobotDoc info = BeanUtil.toBean(this, RobotDoc.class);
        KefuContext context = KefuContext.getKefuContext();
        info.setUpdateUser(context.getUserId());
        info.setUpdateTime(context.getNow());
        return info;

    }

}